package org.zhadoop.streaming.expression;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 运算表达式抽象类
 * @author zwd
 *
 */
public abstract class OperatorBasedExpression implements IExpression{
	/**
	 * 序列化id
	 */
	private static final long serialVersionUID = 966198637888202605L;

	/**
	 * 日志打印对象
	 */
	private static final Logger LOG = LoggerFactory.getLogger(OperatorBasedExpression.class);
	
	/**
	 * 运算对象
	 */
	private ExpressionOperator op = null;
	
	/**
	 * 左表达式
	 */
	private IExpression leftExpr = null;
	
	/**
	 * 有表达式
	 */
	private IExpression rightExpr = null;
	
	/**
	 * 表达式返回类型
	 */
	private Class<?> type = null;
	
	public OperatorBasedExpression(ExpressionOperator op, IExpression leftExpr, IExpression rightExpr) {
		if(null == op || null == leftExpr || null == rightExpr){
			String msg = "Illegal operator expression argument.";
			LOG.error(msg);
			throw new IllegalArgumentException(msg);
		}
		this.op = op;
		this.leftExpr = leftExpr;
		this.rightExpr = rightExpr;
	}

	public ExpressionOperator getOp() {
		return op;
	}

	public void setOp(ExpressionOperator op) {
		this.op = op;
	}

	public IExpression getLeftExpr() {
		return leftExpr;
	}

	public void setLeftExpr(IExpression leftExpr) {
		this.leftExpr = leftExpr;
	}

	public IExpression getRightExpr() {
		return rightExpr;
	}

	public void setRightExpr(IExpression rightExpr) {
		this.rightExpr = rightExpr;
	}

	public Class<?> getType() {
		return type;
	}

	public void setType(Class<?> type) {
		this.type = type;
	}	

}
